package indi.defoliation.unknownrpg.api.rpgevent.entity;

import org.bukkit.entity.Entity;

import indi.defoliation.unknownrpg.api.attribute.Attribute;
import indi.defoliation.unknownrpg.api.rpgevent.Cancellable;

public class EntityAttackEvent extends EntityEvent implements Cancellable{
	
	private final Double damage;
	private final Double finalDamage;
	private Double changeValue;
	
	private final Entity victim;
	
	private boolean cancel = false;
	
	public EntityAttackEvent(Entity what,Entity victim,Double damage,Double finalDamage) {
		super(what);
		this.damage=damage;
		this.finalDamage=finalDamage;
		this.victim=victim;
		this.changeValue=damage;
	}
	
	public Double getDamage() {
		return damage;
	}
	
	public Double getChangeDamage() {
		return this.changeValue;
	}
	
	public Double getFinalDamage() {
		return this.finalDamage; 
	}
	
	public Entity getVictim() {
		return victim;
	}
	
	public void setDamage(Attribute operator,Double damage) {
		this.changeValue=damage;
		super.getTable().addAction(operator, super.clone());
	}
	@Override
	public boolean isCancelled() {
		return cancel;
	}

	@Override
	public void setCancelled(Attribute operoter, boolean cance) {
		if(this.cancel==cance)
			return;
		this.cancel=cance;
		super.getTable().addAction(operoter, super.clone());
	}
}
